//
// C++ Implementation: pexplorer
//
// Description: 
//
//
// Author: Os3 s.r.l. <xgui@os3.it>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//

#include <iostream>
#include <string>
#include <map>

#include "xgui.h"

int main(int argc, char *argv[])
{
	if(argc < 2) { 
		std::cerr << "Must specify the tag for which you want available properties as parameter" << std::endl; 
		std::cerr << "Syntax: " << argv[0] << " <tagname> <plugin_to_load> ... " << std::endl;
		return 1; 
	}
	std::string tag = argv[1];

	xgui::Master::InitDynamicClasses();

	for(int i=2; i<argc; ++i)
		xgui::Master::LoadLibrary(argv[i]);

	xgui::ClassInfo * cinfo = xgui::Master::FindClassByTag(tag);

	if (!cinfo) { 
		std::cerr << "Unable to find dynamic informations for tag: " << tag << std::endl;
		return 1;
	}

	std::cout << "<<<<<< " << cinfo->className() << " >>>>>> " << std::endl;

	std::cout << "------ CONSTRUCTION PROPERTIES ------" << std::endl;
	const std::map<std::string, bool> & init_map = cinfo->initProperties();
	for ( std::map<std::string, bool>::const_iterator iter = init_map.begin();
		iter != init_map.end(); ++iter ) {
		std::cout << iter->first << (iter->second ? "(REQUIRED)" : "") << std::endl;
	}

	std::cout << "------ PROPERTIES ------" << std::endl;
	std::vector<std::string> prop_list = cinfo->properties();
	for ( std::vector<std::string>::iterator iter = prop_list.begin();
		iter != prop_list.end(); ++iter ) {
		if ( (cinfo->hasProperty(*iter) == xgui::PROPERTY_READ_WRITE) )
			std::cout << (*iter) << "(RW)" << std::endl;
		else
			std::cout << (*iter) << "(RO)" << std::endl;
	}

	std::cout << "------ METHODS ------" << std::endl;
	std::vector<std::string> methods = cinfo->methods();
	for ( std::vector<std::string>::iterator iter = methods.begin();
		iter != methods.end(); ++iter ) {
		std::cout << (*iter) << std::endl;
	}

	return 0;
}
